import 'package:flutter/material.dart';

//https://blog.csdn.net/weixin_52418790/article/details/136186350
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
          colorScheme: const ColorScheme(
              primary: Colors.blueAccent, //按钮字体颜色
              surfaceVariant: Colors.orange,
              secondary: Colors.yellowAccent,
              background: Colors.white, //整个页面背景色
              error: Colors.red,
              brightness: Brightness.light,
              onBackground: Colors.blueAccent, //边框按钮边框颜色
              outlineVariant: Colors.amber,
              onError: Colors.yellow,
              onPrimary: Colors.redAccent,
              onSecondary: Colors.blueAccent,
              onSurface: Color.fromARGB(255, 54, 54, 184),
              surface: Colors.blue) //整个标题栏颜色
          // primarySwatch: Colors.blue, // 设置主色调,无效，怎么设都是白色
          ),
      home: const Tabs(),
    );
  }
}

class Tabs extends StatefulWidget {
  const Tabs({super.key});

  @override
  State<Tabs> createState() => _TabsState();
}

class _TabsState extends State<Tabs> {
  int currIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("P33a")),
      body: const Text("data"),
      bottomNavigationBar: BottomNavigationBar(
          showSelectedLabels: true,
          showUnselectedLabels: true,
          unselectedItemColor: Colors.grey,
          currentIndex: currIndex,
          onTap: (index) {
            setState(() {
              currIndex = index; //切换选中页
            });
          },
          items: const [
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label: "首页",
            ),
            BottomNavigationBarItem(icon: Icon(Icons.category), label: "分类"),
            BottomNavigationBarItem(icon: Icon(Icons.settings), label: "设置"),
            BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
          ]),
    );
  }
}
